#include "EventObject.h"
#include "EventServer.h"

#include <config.h>
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#define _(String) gettext(String)

int
main(int argc, char **argv)
{
	EventServer *server;
	int	     status;

	setlocale(LC_ALL, "");
	bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
	textdomain(GETTEXT_PACKAGE);

	if (argc != 2) {
		fprintf(stderr, _("Please specify the running directory! (see -h/--help)\n"));
		return 1;
	}

	if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
		printf("EventServer %s\n", PACKAGE_VERSION);
		return 0;
	}
	if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
		printf("EventServer help\n%s\n%s\n%s\n%s\n",
		       _("Usage:\n\tevent_server [Runtime directory]"),
		       _("Options:"),
		       _("\t-h/--help\tDisplay this help information."),
		       _("\t-v/--version\tShow program version."));
		return 0;
	}

	printf(_("The server starts running.\n"));

	server = event_server_new();
	event_server_set_runtime_path(server, argv[1]);
	status = event_server_run(server);

	event_object_unref(server);
	return status;
}